import React, { Component } from "react";
import { createPortal } from "react-dom";

class Child extends Component {
  render() {
    return createPortal(<div>child组件</div>, document.querySelector("body"));
  }
}

class App extends Component {
  state = {};
  render() {
    return (
      <div className="wrap">
        <h2>portal</h2>
        <Child />
      </div>
    );
  }
}

export default App;
